home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / baraduke.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  21KB  |  601 lines

  1. /***************************************************************************
  2.  
  3. Baraduke/Metro-Cross (c) Namco 1985
  4.  
  5. Driver by Manuel Abadia <manu@teleline.es>
  6.  
  7. TO DO:
  8.     - in Metro-Cross test mode, inputs are unnecessarily repeated, so
  9.     selecting the sound you want to listen to is almost impossible.
  10.     - remove the sound kludge in Baraduke.
  11.  
  12. ***************************************************************************/
  13.  
  14. #include "driver.h"
  15. #include "vidhrdw/generic.h"
  16. #include "cpu/m6800/m6800.h"
  17.  
  18. static unsigned char *sharedram;
  19. extern unsigned char *baraduke_textram, *spriteram, *baraduke_videoram;
  20.  
  21. /* from vidhrdw/baraduke.c */
  22. int baraduke_vh_start( void );
  23. int metrocrs_vh_start( void );
  24. void baraduke_vh_stop( void );
  25. void baraduke_vh_screenrefresh( struct osd_bitmap *bitmap,int full_refresh );
  26. void metrocrs_vh_screenrefresh( struct osd_bitmap *bitmap,int full_refresh );
  27. READ_HANDLER( baraduke_textlayer_r );
  28. READ_HANDLER( baraduke_videoram_r );
  29. WRITE_HANDLER( baraduke_textlayer_w );
  30. WRITE_HANDLER( baraduke_videoram_w );
  31. WRITE_HANDLER( baraduke_scroll0_w );
  32. WRITE_HANDLER( baraduke_scroll1_w );
  33. void baraduke_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  34.  
  35. static int inputport_selected;
  36.  
  37. static WRITE_HANDLER( inputport_select_w )
  38. {
  39.     if ((data & 0xe0) == 0x60)
  40.         inputport_selected = data & 0x07;
  41.     else if ((data & 0xe0) == 0xc0)
  42.     {
  43.         coin_lockout_global_w(0,~data & 1);
  44.         coin_counter_w(0,data & 2);
  45.         coin_counter_w(1,data & 4);
  46.     }
  47. }
  48.  
  49. #define reverse_bitstrm(data) ((data & 0x01) << 4) | ((data & 0x02) << 2) | (data & 0x04) \
  50.                             | ((data & 0x08) >> 2) | ((data & 0x10) >> 4)
  51.  
  52. static READ_HANDLER( inputport_r )
  53. {
  54.     int data = 0;
  55.  
  56.     switch (inputport_selected){
  57.         case 0x00:    /* DSW A (bits 0-4) */
  58.             data = ~(reverse_bitstrm(readinputport(0) & 0x1f)); break;
  59.         case 0x01:    /* DSW A (bits 5-7), DSW B (bits 0-1) */
  60.             data = ~(reverse_bitstrm((((readinputport(0) & 0xe0) >> 5) | ((readinputport(1) & 0x03) << 3)))); break;
  61.         case 0x02:    /* DSW B (bits 2-6) */
  62.             data = ~(reverse_bitstrm(((readinputport(1) & 0x7c) >> 2))); break;
  63.         case 0x03:    /* DSW B (bit 7), DSW C (bits 0-3) */
  64.             data = ~(reverse_bitstrm((((readinputport(1) & 0x80) >> 7) | ((readinputport(2) & 0x0f) << 1)))); break;
  65.         case 0x04:    /* coins, start */
  66.             data = ~(readinputport(3)); break;
  67.         case 0x05:    /* 2P controls */
  68.             data = ~(readinputport(5)); break;
  69.         case 0x06:    /* 1P controls */
  70.             data = ~(readinputport(4)); break;
  71.         default:
  72.             data = 0xff;
  73.     }
  74.  
  75.     return data;
  76. }
  77.  
  78. static WRITE_HANDLER( baraduke_lamps_w )
  79. {
  80.     osd_led_w(0, (data & 0x08) >> 3);
  81.     osd_led_w(1, (data & 0x10) >> 4);
  82. }
  83.  
  84. READ_HANDLER( baraduke_sharedram_r )
  85. {
  86.     return sharedram[offset];
  87. }
  88. WRITE_HANDLER( baraduke_sharedram_w )
  89. {
  90.     sharedram[offset] = data;
  91. }
  92.  
  93. static struct MemoryReadAddress baraduke_readmem[] =
  94. {
  95.     { 0x0000, 0x17ff, MRA_RAM },                /* RAM */
  96.     { 0x1800, 0x1fff, MRA_RAM },                /* Sprite RAM */
  97.     { 0x2000, 0x3fff, baraduke_videoram_r },    /* Video RAM */
  98.     { 0x4000, 0x40ff, namcos1_wavedata_r },        /* PSG device, shared RAM */
  99.     { 0x4000, 0x43ff, baraduke_sharedram_r },    /* shared RAM with the MCU */
  100.     { 0x4800, 0x4fff, MRA_RAM },                /* video RAM (text layer) */
  101.     { 0x6000, 0xffff, MRA_ROM },                /* ROM */
  102.     { -1 }
  103. };
  104.  
  105. static struct MemoryWriteAddress baraduke_writemem[] =
  106. {
  107.     { 0x0000, 0x17ff, MWA_RAM },                /* RAM */
  108.     { 0x1800, 0x1fff, MWA_RAM, &spriteram },    /* Sprite RAM */
  109.     { 0x2000, 0x3fff, baraduke_videoram_w, &baraduke_videoram },/* Video RAM */
  110.     { 0x4000, 0x40ff, namcos1_wavedata_w },        /* PSG device, shared RAM */
  111.     { 0x4000, 0x43ff, baraduke_sharedram_w, &sharedram },/* shared RAM with the MCU */
  112.     { 0x4800, 0x4fff, MWA_RAM, &baraduke_textram },/* video RAM (text layer) */
  113.     { 0x8000, 0x8000, watchdog_reset_w },        /* watchdog reset */
  114. //    { 0x8800, 0x8800, MWA_NOP },                /* ??? */
  115.     { 0xb000, 0xb002, baraduke_scroll0_w },        /* scroll (layer 0) */
  116.     { 0xb004, 0xb006, baraduke_scroll1_w },        /* scroll (layer 1) */
  117.     { 0x6000, 0xffff, MWA_ROM },                /* ROM */
  118.     { -1 }
  119. };
  120.  
  121. READ_HANDLER( soundkludge_r )
  122. {
  123.     static int counter;
  124.  
  125.     return ((counter++) >> 4) & 0xff;
  126. }
  127.  
  128. static struct MemoryReadAddress mcu_readmem[] =
  129. {
  130.     { 0x0000, 0x001f, hd63701_internal_registers_r },/* internal registers */
  131.     { 0x0080, 0x00ff, MRA_RAM },                    /* built in RAM */
  132.     { 0x1000, 0x10ff, namcos1_wavedata_r },            /* PSG device, shared RAM */
  133.     { 0x1105, 0x1105, soundkludge_r },                /* cures speech */
  134.     { 0x1100, 0x113f, MRA_RAM },                    /* PSG device */
  135.     { 0x1000, 0x13ff, baraduke_sharedram_r },        /* shared RAM with the 6809 */
  136.     { 0x8000, 0xbfff, MRA_ROM },                    /* MCU external ROM */
  137.     { 0xc000, 0xc800, MRA_RAM },                    /* RAM */
  138.     { 0xf000, 0xffff, MRA_ROM },                    /* MCU internal ROM */
  139.     { -1 }
  140. };
  141.  
  142. static struct MemoryWriteAddress mcu_writemem[] =
  143. {
  144.     { 0x0000, 0x001f, hd63701_internal_registers_w },/* internal registers */
  145.     { 0x0080, 0x00ff, MWA_RAM },                /* built in RAM */
  146.     { 0x1000, 0x10ff, namcos1_wavedata_w, &namco_wavedata },/* PSG device, shared RAM */
  147.     { 0x1100, 0x113f, namcos1_sound_w, &namco_soundregs },/* PSG device */
  148.     { 0x1000, 0x13ff, baraduke_sharedram_w },    /* shared RAM with the 6809 */
  149. //    { 0x8000, 0x8000, MWA_NOP },                /* ??? */
  150. //    { 0x8800, 0x8800, MWA_NOP },                /* ??? */
  151.     { 0x8000, 0xbfff, MWA_ROM },                /* MCU external ROM */
  152.     { 0xc000, 0xc800, MWA_RAM },                /* RAM */
  153.     { 0xf000, 0xffff, MWA_ROM },                /* MCU internal ROM */
  154.     { -1 }
  155. };
  156.  
  157. static struct IOReadPort mcu_readport[] =
  158. {
  159.     { HD63701_PORT1, HD63701_PORT1, inputport_r },            /* input ports read */
  160.     { -1 }    /* end of table */
  161. };
  162.  
  163. static struct IOWritePort mcu_writeport[] =
  164. {
  165.     { HD63701_PORT1, HD63701_PORT1, inputport_select_w },    /* input port select */
  166.     { HD63701_PORT2, HD63701_PORT2, baraduke_lamps_w },        /* lamps */
  167.     { -1 }    /* end of table */
  168. };
  169.  
  170. INPUT_PORTS_START( baraduke )
  171.     PORT_START    /* DSW A */
  172.     PORT_SERVICE( 0x01, IP_ACTIVE_HIGH )
  173.     PORT_DIPNAME( 0x06, 0x00, DEF_STR( Lives ) )
  174.     PORT_DIPSETTING(    0x04, "2" )
  175.     PORT_DIPSETTING(    0x00, "3" )
  176.     PORT_DIPSETTING(    0x02, "4" )
  177.     PORT_DIPSETTING(    0x06, "5" )
  178.     PORT_DIPNAME( 0x18, 0x00, DEF_STR( Coin_A ) )
  179.     PORT_DIPSETTING(    0x18, DEF_STR( 3C_1C ) )
  180.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  181.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  182.     PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
  183.     PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
  184.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  185.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  186.     PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
  187.     PORT_DIPSETTING(    0xc0, DEF_STR( 3C_1C ) )
  188.     PORT_DIPSETTING(    0x40, DEF_STR( 2C_1C ) )
  189.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  190.     PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) )
  191.  
  192.     PORT_START    /* DSW B */
  193.     PORT_DIPNAME( 0x03, 0x00, DEF_STR( Bonus_Life ) )
  194.     PORT_DIPSETTING(    0x02, "Every 10k" )
  195.     PORT_DIPSETTING(    0x00, "10k and every 20k" )
  196.     PORT_DIPSETTING(    0x01, "Every 20k" )
  197.     PORT_DIPSETTING(    0x03, "None" )
  198.     PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Difficulty ) )
  199.     PORT_DIPSETTING(    0x08, "Easy" )
  200.     PORT_DIPSETTING(    0x00, "Normal" )
  201.     PORT_DIPSETTING(    0x04, "Hard" )
  202.     PORT_DIPSETTING(    0x0c, "Very hard" )
  203.     PORT_BITX(    0x10, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack test", IP_KEY_NONE, IP_JOY_NONE )
  204.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  205.     PORT_DIPSETTING(    0x10, DEF_STR( On ) )
  206.     PORT_DIPNAME( 0x20, 0x00, "Freeze" )
  207.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  208.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  209.     PORT_DIPNAME( 0x40, 0x00, "Allow continue from last level" )
  210.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  211.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  212.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  213.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  214.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  215.  
  216.     PORT_START    /* DSW C */
  217.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
  218.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  219.     PORT_DIPSETTING(    0x01, DEF_STR( On ) )
  220.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
  221.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  222.     PORT_DIPSETTING(    0x02, DEF_STR( On ) )
  223.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
  224.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  225.     PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
  226.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SERVICE ) /* Another service dip */
  227.     PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
  228.  
  229.     PORT_START    /* IN 0 */
  230.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )
  231.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
  232.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN2 )
  233.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START1 )
  234.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 )
  235.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
  236.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  237.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  238.  
  239.     PORT_START    /* IN 1 */
  240.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  241.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  242.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  243.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY )
  244.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1 )
  245.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
  246.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  247.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  248.  
  249.     PORT_START    /* IN 2 */
  250.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  251.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  252.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  253.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  254.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2 )
  255.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
  256.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  257.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  258. INPUT_PORTS_END
  259.  
  260. INPUT_PORTS_START( metrocrs )
  261.     PORT_START    /* DSW A */
  262.     PORT_SERVICE( 0x01, IP_ACTIVE_HIGH )
  263.     PORT_DIPNAME( 0x06, 0x00, DEF_STR( Coin_A ) )
  264.     PORT_DIPSETTING(    0x06, DEF_STR( 3C_1C ) )
  265.     PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
  266.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  267.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
  268.     PORT_DIPNAME( 0x18, 0x00, DEF_STR( Difficulty ) )
  269.     PORT_DIPSETTING(    0x10, "Easy" )
  270.     PORT_DIPSETTING(    0x00, "Normal" )
  271.     PORT_DIPSETTING(    0x08, "Hard" )
  272.     PORT_DIPSETTING(    0x18, "Very hard" )
  273.     PORT_DIPNAME( 0x20, 0x00, "Allow Continue" )
  274.     PORT_DIPSETTING(    0x20, DEF_STR( No ) )
  275.     PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
  276.     PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
  277.     PORT_DIPSETTING(    0xc0, DEF_STR( 3C_1C ) )
  278.     PORT_DIPSETTING(    0x40, DEF_STR( 2C_1C ) )
  279.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  280.     PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) )
  281.  
  282.     PORT_START    /* DSW B */
  283.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )
  284.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  285.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  286.     PORT_BITX(    0x02, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack test", IP_KEY_NONE, IP_JOY_NONE )
  287.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  288.     PORT_DIPSETTING(    0x02, DEF_STR( On ) )
  289.     PORT_DIPNAME( 0x04, 0x00, "Freeze" )
  290.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  291.     PORT_DIPSETTING(    0x04, DEF_STR( On ) )
  292.     PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
  293.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  294.     PORT_DIPSETTING(    0x08, DEF_STR( On ) )
  295.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
  296.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  297.     PORT_DIPSETTING(    0x10, DEF_STR( On ) )
  298.     PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
  299.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  300.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  301.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
  302.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  303.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  304.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  305.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  306.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  307.  
  308.     PORT_START    /* DSW C */
  309.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
  310.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  311.     PORT_DIPSETTING(    0x01, DEF_STR( On ) )
  312.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
  313.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  314.     PORT_DIPSETTING(    0x02, DEF_STR( On ) )
  315.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
  316.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  317.     PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
  318.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SERVICE ) /* Another service dip */
  319.     PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
  320.  
  321.     PORT_START    /* IN 0 */
  322.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )
  323.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
  324.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN2 )
  325.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START1 )
  326.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 )
  327.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
  328.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  329.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  330.  
  331.     PORT_START    /* IN 1 */
  332.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  333.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  334.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  335.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY )
  336.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1 )
  337.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
  338.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  339.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  340.  
  341.     PORT_START    /* IN 2 */
  342.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  343.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  344.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  345.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  346.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2 )
  347.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
  348.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  349.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  350. INPUT_PORTS_END
  351.  
  352.  
  353.  
  354. static struct GfxLayout text_layout =
  355. {
  356.     8,8,        /* 8*8 characters */
  357.     512,        /* 512 characters */
  358.     2,            /* 2 bits per pixel */
  359.     { 0, 4 },    /* the bitplanes are packed in the same byte */
  360.     { 8*8, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 },
  361.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  362.     16*8        /* every char takes 16 consecutive bytes */
  363. };
  364.  
  365. static struct GfxLayout tile_layout1 =
  366. {
  367.     8,8,        /* 8*8 characters */
  368.     512,        /* 512 characters */
  369.     3,            /* 3 bits per pixel */
  370.     { 0x8000*8, 0, 4 },
  371.     { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3 },
  372.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  373.     16*8        /* every char takes 16 consecutive bytes */
  374. };
  375.  
  376. static struct GfxLayout tile_layout2 =
  377. {
  378.     8,8,        /* 8*8 characters */
  379.     512,        /* 512 characters */
  380.     3,            /* 3 bits per pixel */
  381.     { 0x8000*8+4, 0x2000*8, 0x2000*8+4 },
  382.     { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3 },
  383.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  384.     16*8        /* every char takes 16 consecutive bytes */
  385. };
  386.  
  387. static struct GfxLayout tile_layout3 =
  388. {
  389.     8,8,        /* 8*8 characters */
  390.     512,        /* 512 characters */
  391.     3,            /* 3 bits per pixel */
  392.     { 0xa000*8, 0x4000*8, 0x4000*8+4 },
  393.     { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3 },
  394.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  395.     16*8        /* every char takes 16 consecutive bytes */
  396. };
  397.  
  398. static struct GfxLayout tile_layout4 =
  399. {
  400.     8,8,        /* 8*8 characters */
  401.     512,        /* 512 characters */
  402.     3,            /* 3 bits per pixel */
  403.     { 0xa000*8+4, 0x6000*8, 0x6000*8+4 },
  404.     { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3 },
  405.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  406.     16*8        /* every char takes 16 consecutive bytes */
  407. };
  408.  
  409. static struct GfxLayout spritelayout =
  410. {
  411.     16,16,        /* 16*16 sprites */
  412.     512,        /* 512 sprites */
  413.     4,            /* 4 bits per pixel */
  414.     { 0, 1, 2, 3 },
  415.     { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4,
  416.         8*4, 9*4, 10*4, 11*4, 12*4, 13*4, 14*4, 15*4 },
  417.     { 8*8*0, 8*8*1, 8*8*2, 8*8*3, 8*8*4, 8*8*5, 8*8*6, 8*8*7,
  418.     8*8*8, 8*8*9, 8*8*10, 8*8*11, 8*8*12, 8*8*13, 8*8*14, 8*8*15 },
  419.     128*8        /* every sprite takes 128 consecutive bytes */
  420. };
  421.  
  422. static struct GfxDecodeInfo gfxdecodeinfo[] =
  423. {
  424.     { REGION_GFX1, 0, &text_layout,        0, 512 },
  425.     { REGION_GFX2, 0, &tile_layout1,    0, 256 },
  426.     { REGION_GFX2, 0, &tile_layout2,    0, 256 },
  427.     { REGION_GFX2, 0, &tile_layout3,    0, 256 },
  428.     { REGION_GFX2, 0, &tile_layout4,    0, 256 },
  429.     { REGION_GFX3, 0, &spritelayout,    0, 128 },
  430.     { -1 }
  431. };
  432.  
  433. static struct namco_interface namco_interface =
  434. {
  435.     49152000/2048,         /* 24000Hz */
  436.     8,                    /* number of voices */
  437.     100,                /* playback volume */
  438.     -1,                    /* memory region */
  439.     0                    /* stereo */
  440. };
  441.  
  442.  
  443. static struct MachineDriver machine_driver_baraduke =
  444. {
  445.     /* basic machine hardware */
  446.     {
  447.         {
  448.             CPU_M6809,
  449.             49152000/32,    /* ??? */
  450.             baraduke_readmem,baraduke_writemem,0,0,
  451.             interrupt,1
  452.         },
  453.         {
  454.             CPU_HD63701,    /* or compatible 6808 with extra instructions */
  455.             49152000/32,    /* ??? */
  456.             mcu_readmem,mcu_writemem,mcu_readport,mcu_writeport,
  457.             interrupt,1
  458.         }
  459.     },
  460.     60,DEFAULT_REAL_60HZ_VBLANK_DURATION,
  461.     100,        /* we need heavy synch */
  462.     0,
  463.  
  464.     /* video hardware */
  465.     36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 },
  466.     gfxdecodeinfo,
  467.     2048,2048*4,
  468.     baraduke_vh_convert_color_prom,
  469.  
  470.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,    /* palette is static but doesn't fit in 256 colors */
  471.     0,
  472.     baraduke_vh_start,
  473.     0,
  474.     baraduke_vh_screenrefresh,
  475.  
  476.     /* sound hardware */
  477.     0,0,0,0,
  478.     {
  479.         {
  480.             SOUND_NAMCO,
  481.             &namco_interface
  482.         }
  483.     }
  484. };
  485.  
  486. static struct MachineDriver machine_driver_metrocrs =
  487. {
  488.     /* basic machine hardware */
  489.     {
  490.         {
  491.             CPU_M6809,
  492.             49152000/32,    /* ??? */
  493.             baraduke_readmem,baraduke_writemem,0,0,
  494.             interrupt,1
  495.         },
  496.         {
  497.             CPU_HD63701,    /* or compatible 6808 with extra instructions */
  498.             49152000/32,    /* ??? */
  499.             mcu_readmem,mcu_writemem,mcu_readport,mcu_writeport,
  500.             interrupt,1
  501.         }
  502.     },
  503.     60,DEFAULT_REAL_60HZ_VBLANK_DURATION,
  504.     100,        /* we need heavy synch */
  505.     0,
  506.  
  507.     /* video hardware */
  508.     36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 },
  509.     gfxdecodeinfo,
  510.     2048,2048*4,
  511.     baraduke_vh_convert_color_prom,
  512.  
  513.     VIDEO_TYPE_RASTER,
  514.     0,
  515.     baraduke_vh_start,
  516.     0,
  517.     metrocrs_vh_screenrefresh,
  518.  
  519.     /* sound hardware */
  520.     0,0,0,0,
  521.     {
  522.         {
  523.             SOUND_NAMCO,
  524.             &namco_interface
  525.         }
  526.     }
  527. };
  528.  
  529. ROM_START( baraduke )
  530.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 6809 code */
  531.     ROM_LOAD( "prg1.9c",    0x6000, 0x02000, 0xea2ea790 )
  532.     ROM_LOAD( "prg2.9a",    0x8000, 0x04000, 0x9a0a9a87 )
  533.     ROM_LOAD( "prg3.9b",    0xc000, 0x04000, 0x383e5458 )
  534.  
  535.     ROM_REGION(  0x10000 , REGION_CPU2 ) /* MCU code */
  536.     ROM_LOAD( "prg4.3b",    0x8000,  0x4000, 0xabda0fe7 )    /* subprogram for the MCU */
  537.     ROM_LOAD( "pl1-mcu.bin",0xf000,     0x1000, 0x6ef08fb3 )    /* The MCU internal code is missing */
  538.                                                             /* Using Pacland code (probably similar) */
  539.     ROM_REGION( 0x02000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  540.     ROM_LOAD( "ch1.3j",        0x00000, 0x2000, 0x706b7fee )    /* characters */
  541.  
  542.     ROM_REGION( 0x0c000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  543.     ROM_LOAD( "ch2.4p",        0x00000, 0x4000, 0xb0bb0710 )    /* tiles */
  544.     ROM_LOAD( "ch3.4n",        0x04000, 0x4000, 0x0d7ebec9 )
  545.     ROM_LOAD( "ch4.4m",        0x08000, 0x4000, 0xe5da0896 )
  546.  
  547.     ROM_REGION( 0x10000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  548.     ROM_LOAD( "obj1.8k",    0x00000, 0x4000, 0x87a29acc )    /* sprites */
  549.     ROM_LOAD( "obj2.8l",    0x04000, 0x4000, 0x72b6d20c )
  550.     ROM_LOAD( "obj3.8m",    0x08000, 0x4000, 0x3076af9c )
  551.     ROM_LOAD( "obj4.8n",    0x0c000, 0x4000, 0x8b4c09a3 )
  552.  
  553.     ROM_REGION( 0x1000, REGION_PROMS )
  554.     ROM_LOAD( "prmcolbg.1n",0x0000, 0x0800, 0x0d78ebc6 )    /* Blue + Green palette */
  555.     ROM_LOAD( "prmcolr.2m",    0x0800, 0x0800, 0x03f7241f )    /* Red palette */
  556. ROM_END
  557.  
  558. ROM_START( metrocrs )
  559.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 6809 code */
  560.     ROM_LOAD( "mc1-3.9c",    0x6000, 0x02000, 0x3390b33c )
  561.     ROM_LOAD( "mc1-1.9a",    0x8000, 0x04000, 0x10b0977e )
  562.     ROM_LOAD( "mc1-2.9b",    0xc000, 0x04000, 0x5c846f35 )
  563.  
  564.     ROM_REGION(  0x10000 , REGION_CPU2 ) /* MCU code */
  565.     ROM_LOAD( "mc1-4.3b",    0x8000, 0x02000, 0x9c88f898 )    /* subprogram for the MCU */
  566.     ROM_LOAD( "pl1-mcu.bin",0xf000,     0x1000, 0x6ef08fb3 )    /* The MCU internal code is missing */
  567.                                                             /* Using Pacland code (probably similar) */
  568.     ROM_REGION( 0x02000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  569.     ROM_LOAD( "mc1-5.3j",    0x00000, 0x2000, 0x9b5ea33a )    /* characters */
  570.  
  571.     ROM_REGION( 0x0c000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  572.     ROM_LOAD( "mc1-7.4p",    0x00000, 0x4000, 0xc9dfa003 )    /* tiles */
  573.     ROM_LOAD( "mc1-6.4n",    0x04000, 0x4000, 0x9686dc3c )
  574.     /* empty space to decode the roms as 3bpp */
  575.  
  576.     ROM_REGION( 0x10000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  577.     ROM_LOAD( "mc1-8.8k",    0x00000, 0x4000, 0x265b31fa )    /* sprites */
  578.     ROM_LOAD( "mc1-9.8l",    0x04000, 0x4000, 0x541ec029 )
  579.     /* 8000-ffff empty */
  580.  
  581.     ROM_REGION( 0x1000, REGION_PROMS )
  582.     ROM_LOAD( "mc1-1.1n",    0x0000, 0x0800, 0x32a78a8b )    /* Blue + Green palette */
  583.     ROM_LOAD( "mc1-2.2m",    0x0800, 0x0800, 0x6f4dca7b )    /* Red palette */
  584. ROM_END
  585.  
  586.  
  587.  
  588. static void init_metrocrs( void )
  589. {
  590.     int i;
  591.     unsigned char *rom = memory_region(REGION_GFX2);
  592.  
  593.     for(i = 0x8000;i < memory_region_length(REGION_GFX2);i++)
  594.         rom[i] = 0xff;
  595. }
  596.  
  597.  
  598.  
  599. GAME( 1985, baraduke, 0, baraduke, baraduke, 0,        ROT0, "Namco", "Baraduke" )
  600. GAME( 1985, metrocrs, 0, metrocrs, metrocrs, metrocrs, ROT0, "Namco", "Metro-Cross" )
  601.